<template>
    <div class="login--box">
      <input v-model="userInfo.phoneNumber" type="text" placeholder="请输入11位手机号" class="phoneNumber"><br>
      <input v-model="userInfo.password" type="text" placeholder="请输入6-12位密码" class="password"><br>
      <span class="span-container">已有账户，<span class="span">忘记密码?</span></span><br>
      <div @click="login" class="login">登录</div>
    </div>
</template>

<script>
    export default {
      name: "login",
      data() {
        return {
          userInfo: {
            phoneNumber: '',
            password: '',
          }
        }
      },
      methods: {
        login() {
          this.$apis.login(this.userInfo)
            .then(data => {
              if (data.data.code === 3001) {
                this.$router.push({name:'home'});
                localStorage.setItem('phoneNumber', this.userInfo.phoneNumber);
                console.log(data)
              }
            })
            .catch(error =>{
              console.log(error)
            });
        }
      },
    }
</script>

<style scoped>
  .phoneNumber,.password{
    width: 80%;
    height: 1.16rem;
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, .1);
    position: relative;
    left: 10%;
    outline: none;
    font-size: .3rem;
  }
  .login--box{
    position: relative;
    top: 1.4rem;
  }
  .span-container{
    width: 80vw;
    height: 1rem;
    display: inline-block;
    line-height: 1rem;
    left: 10vw;
    right: 10vw;
    text-align: right;
    position: relative;
  }
  .span{
    color: #166ee4;
  }
  .login{
    position: relative;
    display: inline-block;
    top: 1rem;
    width: 70%;
    height: 1rem;
    background-color: #3868E4;
    text-align: center;
    line-height: 1rem;
    color: white;
    left: 15%;
    border-radius: 1rem;
    font-size: .45rem;
  }
</style>
